#!/usr/bin/perl 


use DBI;
use CGI;
use TTraker;

my $dbh;
initialize_dbi();

my $form_ref = &parse_input;
print_header();

my %FORM_DATA = %$form_ref; 

my $num = $FORM_DATA{'empNum'};
my $name = $FORM_DATA{'empName'};
my $job = $FORM_DATA{'empJob'};
my $loc = $FORM_DATA{'empLoc'};
	

my $mNum = $FORM_DATA{'mNum'};
my $mFir = $FORM_DATA{'mFir'};
my $mLas = $FORM_DATA{'mLas'};
my $mLoc = $FORM_DATA{'mLoc'};
my $mFac = $FORM_DATA{'mFac'}; 		
my $mAge = $FORM_DATA{'mAge'};
my $mJob = $FORM_DATA{'mJob'};
my $mPay = $FORM_DATA{'mPay'};
my $mRat = $FORM_DATA{'mRat'};
my $mLog = $FORM_DATA{'mLog'};
my $mAct = $FORM_DATA{'mAct'};
	
"$mNum, $mFir, $mLas, $mLoc, $mFac, $mAge, $mJob, $mPay, $mRat, $mLog, $mAct<br/>";

my $message = "";
if ( $mNum == "" || $mFir eq "" || $mLas eq "" || $mLoc eq "" || $mFac eq "" || $mAge eq "" || $mJob eq "" || $mPay eq "" || $mRat eq "" || $mLog eq "" || $mAct eq "" ) {
	$message = "All fields must be filled in!";
	& update_employee_data_msg ($mNum, $mFir, $mLas, $mLoc, $mFac, $mAge, $mJob, $mPay, $mRat, $mLog, $mAct);
} else {
	update_employee ($mNum, $mFir, $mLas, $mLoc, $mFac, $mAge, $mJob, $mPay, $mRat, $mLog, $mAct);
	pay_activity_screen_from_pm ($num, $name,$job, $loc);
}	 

db_disconnect();

##################### SUBROUTINES FOLLOW  #####################


sub update_employee_data_msg
{
	my $mNum = $_[0];
	my $mFir = $_[1];
	my $mLas = $_[2];
	my $mLoc = $_[3];
	my $mFac = $_[4];  		
	my $mAge = $_[5];
	my $mJob = $_[6];
	my $mPay = $_[7];
	my $mRat = $_[8];
	my $mLog = $_[9];
	my $mAct = $_[10];
#  	print "$_[0], $_[1], $_[2], $_[3], $_[4], $_[5], $_[6], $_[7], $_[8], $_[9], $_[10]<br/>"; 

print <<ENDHEADER;
  <html>
  <head>
  <link rel='stylesheet' type='text/css' href='${css_ref}trak.css' />
  <script type='text/javascript' src='${js_ref}trak.js'></script>
  <title>trak_03_adm_add_new_client.pl</title>
  </head>
  <body>
  <h2><center>${banner}</center></h2>
  <hr/>
  &nbsp&nbsp&nbsp&nbsp&nbsp
  <div id = "box5_1"> 
  <h3>Update Existing Employee Data</h3>
  </div>
	<form id="box2" autocomplete="off" name="empID" action="${cgi_ref}trak_04_update_employee_data.pl" method="post">
	<input type="hidden" name=empNum value='$num'/>
	<input type="hidden" name=empName value='$name'/>
	<input type="hidden" name=mNum value='$mNum'/>

	<br/>
	<table>
		<tr>
			<td>Emp #: &nbsp</td>
			<td>$mNum &nbsp&nbsp</td>
		</tr>
		<tr>
			<td>First Name: &nbsp</td>
			<td><input type="text" value = "$mFir" size=24 name=mFir />&nbsp&nbsp</td>
		</tr>
		<tr>
			<td>Last Name: </td>
			<td><input type="text" value = "$mLas" size=24 name=mLas />&nbsp&nbsp</td>
		</tr>
		<tr>
		   <td>Login ID: </td>
		   <td><input type="text" value = "$mLog" size=24 name=mLog />&nbsp&nbsp</td>
		</tr>
		<tr>
			<td>Location: </td>
			<td><input type="text" value= "$mLoc" size=5 name=mLoc />&nbsp&nbsp</td>
		</tr>
		<tr>
   		<td>Facility #:</td>
   		<td><input type="text" value = "$mFac" size=5 name=mFac />&nbsp&nbsp</td>
   	<tr/>
   	<tr>
   		<td>Agency:</td>
   		<td><input type="text" value = "$mAge" size=5 name=mAge />&nbsp&nbsp</td>
   	<tr/>
   	<tr>
	   	<td>Pay Cat: </td>
	   	<td><input type="text" value = "$mPay" size=5 name=mPay />&nbsp&nbsp</td>
		</tr>
		<tr>
	   	<td>Job: </td>
	   	<td><input type="text" value = "$mJob" size=5 name=mJob />&nbsp&nbsp</td>
		</tr>
		<tr>
   		<td>Rate: </td>
   		<td><input type="text" size=5 value = "$mRat" name=prmRate />&nbsp&nbsp<td>
		</tr>
		<tr>
   		<td>Active: </td>
   		<td><input type="text" size=5 value = "$mAct" name=prmNum />&nbsp&nbsp<td>
		</tr>
	</table>	
   	<br/>
   	<input type="submit" value="Update Employee Data">
   	<br/><br/>
 	<a href="${cgi_ref}trak_00_start_up.pl">Return to Log-In</a><br/>
 	<br/><br/>
 	<b id="warn">$message</b><br/><br/>
 </form>
 </div>
 </body>
 </html>
ENDHEADER

}


